<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>旅客详情 - 航空订票系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="/flightbooking/">航空订票系统</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/flights">航班管理</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/flightbooking/passengers">旅客管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/tickets">票务管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/dashboard">统计面板</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="/flightbooking/">首页</a></li>
                <li class="breadcrumb-item"><a href="/flightbooking/passengers">旅客管理</a></li>
                <li class="breadcrumb-item active" aria-current="page">旅客详情</li>
            </ol>
        </nav>

        <div class="card">
            <div class="card-header bg-primary text-white">
                <h5 class="mb-0">旅客详情</h5>
            </div>
            <div class="card-body">
                <div class="row" th:if="${passenger != null}">
                    <div class="col-md-6">
                        <table class="table table-bordered">
                            <tr>
                                <th width="150">旅客ID</th>
                                <td th:text="${passenger.passengerId}">1</td>
                            </tr>
                            <tr>
                                <th>姓名</th>
                                <td th:text="${passenger.name}">张三</td>
                            </tr>
                            <tr>
                                <th>身份证号</th>
                                <td th:text="${passenger.idCard}">110101199001011234</td>
                            </tr>
                            <tr>
                                <th>联系电话</th>
                                <td th:text="${passenger.phone}">13800138000</td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-6">
                        <table class="table table-bordered">
                            <tr>
                                <th width="150">电子邮箱</th>
                                <td th:text="${passenger.email}">zhangsan@example.com</td>
                            </tr>
                            <tr>
                                <th>历史购票金额</th>
                                <td th:text="${passenger.totalPurchase}">0.00</td>
                            </tr>
                            <tr>
                                <th>VIP折扣率</th>
                                <td>
                                    <span th:text="${passenger.vipDiscount}">1.00</span>
                                    <span class="badge badge-success" th:if="${passenger.vipDiscount < 1}">VIP</span>
                                </td>
                            </tr>
                            <tr>
                                <th>注册时间</th>
                                <td th:text="${#dates.format(passenger.registrationDate, 'yyyy-MM-dd HH:mm')}">2023-06-01 10:00</td>
                            </tr>
                        </table>
                    </div>
                </div>
                
                <div class="alert alert-danger" th:if="${passenger == null}">
                    未找到旅客信息
                </div>
                
                <div class="mt-3" th:if="${passenger != null}">
                    <a th:href="@{/passengers/edit/{id}(id=${passenger.passengerId})}" class="btn btn-warning">编辑旅客</a>
                    <a th:href="@{/passengers/delete/{id}(id=${passenger.passengerId})}" class="btn btn-danger" 
                       onclick="return confirm('确定要删除此旅客吗？删除后将无法恢复，且可能影响相关订票数据。')">删除旅客</a>
                    <a href="/flightbooking/passengers" class="btn btn-secondary">返回列表</a>
                </div>
            </div>
        </div>

        <div class="card mt-4" th:if="${passenger != null}">
            <div class="card-header bg-primary text-white">
                <h5 class="mb-0">购票记录</h5>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>票号</th>
                                <th>航班号</th>
                                <th>航空公司</th>
                                <th>行程</th>
                                <th>座位号</th>
                                <th>购票时间</th>
                                <th>实付金额</th>
                                <th>票状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr th:each="ticket : ${tickets}">
                                <td th:text="${ticket.ticketId}">1</td>
                                <td th:text="${ticket.flightId}">CA1234</td>
                                <td th:text="${ticket.flight != null ? ticket.flight.airlineCompany : '未知'}">中国国际航空</td>
                                <td th:text="${ticket.flight != null ? ticket.flight.departureCity + ' → ' + ticket.flight.arrivalCity : '未知'}">北京 → 上海</td>
                                <td th:text="${ticket.seatNumber}">12A</td>
                                <td th:text="${#dates.format(ticket.purchaseDate, 'yyyy-MM-dd HH:mm')}">2023-07-01 08:00</td>
                                <td th:text="${ticket.actualPrice}">1200.00</td>
                                <td>
                                    <span th:if="${ticket.status == '已预订'}" class="badge badge-warning">已预订</span>
                                    <span th:if="${ticket.status == '已出票'}" class="badge badge-success">已出票</span>
                                    <span th:if="${ticket.status == '已取消'}" class="badge badge-danger">已取消</span>
                                    <span th:if="${ticket.status == '已退票'}" class="badge badge-secondary">已退票</span>
                                    <span th:if="${ticket.status == '已使用'}" class="badge badge-info">已使用</span>
                                </td>
                                <td>
                                    <div class="btn-group btn-group-sm">
                                        <a th:href="@{/tickets/{id}(id=${ticket.ticketId})}" class="btn btn-info">详情</a>
                                        <a th:if="${ticket.status == '已预订'}" th:href="@{/tickets/cancel/{id}(id=${ticket.ticketId})}" 
                                           class="btn btn-danger" onclick="return confirm('确定要取消此票吗？')">取消</a>
                                    </div>
                                </td>
                            </tr>
                            <tr th:if="${#lists.isEmpty(tickets)}">
                                <td colspan="9" class="text-center">该旅客暂无购票记录</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <footer class="bg-dark text-light mt-5 py-3">
        <div class="container text-center">
            <p class="mb-0">© 2023 航空订票系统 - JZA04</p>
        </div>
    </footer>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 